//
//  PPViewController.m
//  CreateWithSuper
//
//  Created by chenjunbo on 2024/5/27.
//  Copyright © 2024 CS. All rights reserved.
//

#import "PPViewController.h"
#import "CSGuideConnectController.h"
#import "CSNetworkHelper.h"
//#import "ADModule.h"
#import "CSPolicyPopView.h"
#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/ASIdentifierManager.h>
#import "CSAttPopView.h"
#import "CSLoadController.h"

@interface PPViewController ()

@property (weak, nonatomic) IBOutlet UIButton *centerButton;

@end

@implementation PPViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];

    NSString *str = [[NSLocale currentLocale]objectForKey:NSLocaleCountryCode];
        
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
       
//        if ([str isEqualToString:@"CN"]){
//            CSAttPopView *popView = [[CSAttPopView alloc]init];
//            popView.modalPresentationStyle = UIModalPresentationOverFullScreen;
//            [self presentViewController:popView animated:NO completion:nil];
//            
//            UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
//            view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
//            [[UIApplication sharedApplication].keyWindow addSubview:view];
//        }
    });
    
}

- (void)setupUI{
    self.centerButton.layer.cornerRadius = 22;
}

- (IBAction)ppTouch:(UIButton *)sender {
    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://qrscanonetool.com/Privacy%20Policy.html"]];
}

- (IBAction)vppTouch:(UIButton *)sender {
    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"https://sites.google.com/view/vpn-privacy-policyhealth/home"]];
}

- (IBAction)termTouch:(UIButton *)sender {
    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://qrscanonetool.com/server.html"]];
}

- (IBAction)encyptTouch:(UIButton *)sender {
    
    if (@available(iOS 14, *)) {
        if (ATTrackingManager.trackingAuthorizationStatus == ATTrackingManagerAuthorizationStatusNotDetermined) {
            [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
                dispatch_async(dispatch_get_main_queue(), ^{

                });
            }];
        } else {

        }
    } else {
        dispatch_async(dispatch_get_main_queue(), ^{

        });
    }
    
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"FirstInGuideConnect"];
        CSLoadController *loadVC = [[CSLoadController alloc]init];
        [[CSNetworkHelper standardInstance]requestConfiguration];
        [UIApplication sharedApplication].keyWindow.rootViewController = loadVC;
        
//        [UIApplication sharedApplication].keyWindow.rootViewController = [CSGuideConnectController new];
    });
    
//    CSPolicyPopView *popView = [[CSPolicyPopView alloc]init];
//    popView.modalPresentationStyle = UIModalPresentationOverFullScreen;
//    [self presentViewController:popView animated:NO completion:nil];
//    
//    UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
//    view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
//    [[UIApplication sharedApplication].keyWindow addSubview:view];
//    
//    
//    popView.okBlock = ^{
//        
//        [view removeFromSuperview];
//
//        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//
//            [UIApplication sharedApplication].keyWindow.rootViewController = [CSGuideConnectController new];
//        });
//    };
//    
//    popView.disBlock = ^{
//        [view removeFromSuperview];
//    };

    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
